package time.after.time.web;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import time.after.time.entity.account.User;
import time.after.time.service.account.AccountManager;
import time.after.time.sys.statics.PasswordHandler;

/**
 * 
 * @author HuMing create in 2012-2-16
 */
@Results( { @Result(name ="jump2", location = "/my/?", type = "redirect") })
public class RegisterAction extends BaseActionSupport {

	private static final long serialVersionUID = -7365482163028803812L;
	private User user;
	@Autowired
	private AccountManager accountManager;
	
	@Override
	public String execute() 
	{
		String pwd=user.getPassword();
		user.setPassword(PasswordHandler.getSaltSourceCode(pwd));
		user.setName(user.getLoginName());
		accountManager.saveUser(user);
		return "jump2";
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
}
